package com.yykj.hospital.server.controller;

import com.yykj.common.vo.ResultVO;
import com.yykj.hospital.client.dto.consultation.template.HospitalConsultationDTO;
import com.yykj.hospital.client.dto.consultation.template.HospitalConsultationDetailDTO;
import com.yykj.hospital.client.dto.consultation.template.HospitalConsultationListDTO;
import com.yykj.hospital.server.service.consultation.HospitalConsultationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/backstage/consultation")
@SuppressWarnings("unchecked")
@Api(tags = "会诊类型相关接口")
public class HospitalConsultationBackstageController {

    @ApiOperation("会诊类型 -- 添加修改 ")
    @PostMapping("/type/edit")
    public ResultVO<HospitalConsultationDTO> editHospitalConsultation(@RequestBody HospitalConsultationDTO hospitalConsultation){
        return ResultVO.success(hospitalConsultationService.editHospitalConsultation(hospitalConsultation));
    }

    @ApiOperation("会诊类型 -- 明细字段 -- 添加修改 ")
    @PostMapping("/type/field/edit")
    public ResultVO<HospitalConsultationDTO> editHospitalConsultationDetail(@RequestBody HospitalConsultationDetailDTO detailDTO){
        return ResultVO.success(hospitalConsultationService.editHospitalConsultationDetail(detailDTO));
    }

    @ApiOperation("会诊类型 -- 明细字段 -- 删除 ")
    @DeleteMapping("/type/field/delete/{id}")
    public ResultVO deleteHospitalConsultationDetail(@PathVariable Integer id){
        hospitalConsultationService.deleteHospitalConsultationDetail(id);
        return ResultVO.success();
    }

    @ApiOperation("会诊类型 -- 列表 ")
    @GetMapping("/type/list/{hospitalId}")
    public ResultVO<List<HospitalConsultationListDTO>> listHospitalConsultation(@PathVariable Integer hospitalId){
        return ResultVO.success(hospitalConsultationService.listHospitalConsultation(hospitalId));
    }

    @ApiOperation("会诊类型 ---字段-- 列表 ")
    @GetMapping("/type/field/{consultationId}")
    public ResultVO<List<HospitalConsultationDetailDTO>> listConsultationFields(@PathVariable Integer consultationId){
        return ResultVO.success(hospitalConsultationService.listConsultationFields(consultationId));
    }

    private HospitalConsultationService hospitalConsultationService;

    @Autowired
    public void setHospitalConsultationService(HospitalConsultationService hospitalConsultationService) {
        this.hospitalConsultationService = hospitalConsultationService;
    }
}
